// import { reqHistactive } from '@/api/index'
import axios from 'axios'

// 子reducer
const userState = { TestData: ['1', '2', '3'] }

const ACTIONS = {
  Test: Symbol(),
}

//  action creator作用是：让组件和仓库通信更优雅
export const UserActions = {
  Test: () => ({ type: ACTIONS.Test, payload: 'abc' }),
  request: () => {
    return async (dispatch: any) => {
      // const res = await reqHistactive()
      const res = await axios.get('https://api.oioweb.cn/api/common/OneDayEnglish')
      console.log(res)
      dispatch({ type: ACTIONS.Test, payload: res })
    }
  },
}

const userReducer = function (state = userState, action: any) {
  const { type, payload } = action
  switch (type) {
    case ACTIONS.Test:
      return { ...state, listMain: payload }
    default:
      return state
  }
}

export default userReducer
